package cn.mimedai.blur;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import cn.mimedai.blurlib.background.BlurBehind;
import cn.mimedai.blurlib.background.OnBlurCompleteListener;
import cn.mimedai.blurlib.dialog.BlurPopWin;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void startBgBlur(View view) {
        BlurBehind.getInstance().execute(this, new OnBlurCompleteListener() {
            @Override
            public void onBlurComplete() {
                startActivity(new Intent(MainActivity.this, BgBlurActivity.class));
            }
        });
    }

    public void startViewBlur(View view) {
        startActivity(new Intent(this, ViewBlurActivity.class));
    }

    public void startDialogBlur(View view) {
        new BlurPopWin.Builder(MainActivity.this)
                //Radius越大耗时越长,被图片处理图像越模糊
                .setRadius(10)
                //设置居中还是底部显示
                .setshowAtLocationType(0)
                .setContent(
                        MainActivity.this.getLayoutInflater().inflate(R.layout.activity_dialog_blur, null, false)).
                onClick(new BlurPopWin.PopupCallback() {
                    @Override
                    public void onClick(@NonNull BlurPopWin blurPopWin) {
                        Toast.makeText(MainActivity.this, "中间被点了",
                                Toast.LENGTH_SHORT).show();
                        blurPopWin.dismiss();
                    }
                }).show(view);
    }
}
